//
// Created by root on 24-7-15.
//
#include "../include/vga.h"
#include "../include/io.h"

volatile static int k = 0;
volatile unsigned int time = 0;

void printk(char *prompt, ...);

void printint(unsigned int d) {
    // int esp;
    // __asm__ __volatile__("movl %%esp,%0" : "+a"(esp)::"memory");
    // printk("INT HAPPEN %d",esp);
    k++;
    printk("cal time reach %d,%d", d,k);
    rollup();
    movcursor(24, 0);
}

void keyboarddrive(char m);

void irq0x20() {
    time++;
    if (time & 0xffffffff == time) {
        time = 0;
    }
    if (time%200==0) {
        // printint(time);
        time =0;
    }
    return;
}

void irq0x21() {
    unsigned char m = inbyte(0x60);
    keyboarddrive(m);
}

void irq(unsigned int irqnum) {
    switch (irqnum) {
        case 0x21: irq0x21();
            break;
        case 0x20: irq0x20();
            break;
        default: printint(irqnum);
    }
    return;
}
